node.h File Reference

#include "macros.h"

Include dependency graph for node.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Namespaces

namespace   mudbox

Classes

class   mudbox::ClassDesc
  This structure represents and describes a class. More...
struct   mudbox::Attribute
  This is an abstract base structure for all attributes. Do not use it directly, use AttributeInstance instead. More...
class   mudbox::AttributeVoid
  Used to insert expanded category item. More...
struct   mudbox::AttributeInstance< type >
  This is a generic attribute which can be used instead of the standard built in types. More...
class   mudbox::AttributePointer< type >
  This class can be used instead of standard pointers, when the pointer target class is derived from the Node class. More...
class   mudbox::AttributeThisPointer
  This class represents a special pointer in the Node class, it always points to the owner. Used internally. More...
class   mudbox::Node
  This is the base class for most classes in the Mudbox SDK. More...
class   mudbox::EventGate
  This class represents an event receiver/triggerer point. More...
class   mudbox::AttributeFloatRange
  This attribute represents a float value which has a minimum and a maximum value. These values will be used in the user interface only, but the user will be able to assign values out of the range to the attribute. More...
class   mudbox::AttributeNumber
  An attribute that can hold a number and uses the specified number of digits when displaying on the UI. More...
class   mudbox::AttributeEnumeration
  This attribute is very similar to the aint type but on the user interface it will be displayed as a combobox, and the user will be able to choose its value from a list. More...
class   mudbox::AttributeFilename
  Similar to AttributeInstance<String> but it provides a button on the interface where the user can browse for a filename. More...
class   mudbox::AttributeTextureFilename
  Represents a special file name attribute that accepts texture files as value. Provides a create new and a browse interface. More...
class   mudbox::AttributeWatch
  A fake attribute used to watch an attribute in your class which is not a member. Its better if you create a copy of the attribute in your class with the same type and link it to the target, but if you do not know the exact type of the other attribute you can use this class. More...
class   mudbox::AttributeBoolCollection
  This attribute is a collection of bools. More...

Defines

#define  DECLARE_CLASS
  This macro should be used in declaration of classes which are inherited from the Node class (or any descendant of that) to fill RTTI information.
#define  IMPLEMENT_SDK_VCLASS2(name, parent0, parent1, displayname, instanceclass, version, streamversion)
#define  IMPLEMENT_SDK_CLASS(name, parent, displayname, instanceclass)   IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, instanceclass, 0, 0 )
#define  IMPLEMENT_VCLASS2(name, parent0, parent1, displayname, version)   IMPLEMENT_SDK_VCLASS2( name, parent0, parent1, displayname, name, version, 0 )
#define  IMPLEMENT_VCLASS(name, parent, displayname, version)   IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, name, version, 0 )
#define  IMPLEMENT_CLASS2(name, parent0, parent1, displayname)   IMPLEMENT_SDK_VCLASS2( name, parent0, parent1, displayname, name, 0, 0 )
#define  IMPLEMENT_CLASS(name, parent, displayname)   IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, name, 0, 0 )
#define  IMPLEMENT_SCLASS(name, parent, displayname, streamversion)   IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, name, 0, streamversion )
  This macro is the same as the IMPLEMENT_CLASS macro, but it also accepts an additional parameter, which is the stream version for the class.
#define  OPERATORS_NOEXCMARK(type)
#define  OPERATORS(type)
#define  PTROPERATORS(type)
#define  aptr   AttributePointer

Typedefs

typedef AttributeVoid  avoid
typedef AttributeInstance<
int > 
aint
  This type has to be used instead of the general int type.
typedef AttributeInstance<
float > 
afloat
  This type has to be used instead of the general float type.
typedef AttributeInstance<
bool > 
abool
  This type has to be used instead of the general bool type.
typedef AttributeInstance<
QString > 
astring
  This type has to be used instead of the String type.
typedef EventGate  aevent
typedef AttributeFloatRange  afloatr
typedef AttributeNumber  anumber
typedef AttributeEnumeration  aenum
typedef AttributeFilename  afilename
typedef AttributeTextureFilename  atexturefilename
typedef AttributeBoolCollection  aboolc

Enumerations

enum   NodeEventType {
  etValueChanged, etSourceChanged, etTargetChanged, etPointerContentChanged,
  etPointerTargetDestroyed, etStatusChanged, etPointerTargetUIChanged, etDeferred,
  etRefreshDialogUI, etEventTriggered = etValueChanged
}
  Possible event types when Node::OnNodeEvent is called. More...

Functions

MBDLL_DECL AttributeWidget *  CreateNewPtrWidget (QWidget *pParent, int iWidth, Attribute *pAttribute, const ClassDesc *pType)
MBDLL_DECL AttributeWidget *  CreateNewBoolWidget (QWidget *pParent, int iWidth, abool *pAttribute)
MBDLL_DECL AttributeWidget *  CreateNewIntWidget (QWidget *pParent, int iWidth, aint *pAttribute)
template<typename type>
bool  operator== (const Attribute &cA, const AttributeInstance< type > &cB)
  This operator compares the two attributes and NOT their values. Returns true only if the two attribute instances are the same (See Node::OnNodeEvent).
template<typename type>
Stream &  operator== (Stream &s, AttributeInstance< type > &c)
template<typename type>
Stream &  operator== (Stream &cStream, AttributePointer< type > &cPointer)
AttributeWidget *  CreateNewEventWidget (QWidget *pParent, int iWidth, EventGate *pAttribute)
  Creates an event widget.
MBDLL_DECL Stream &  operator== (Stream &s, afloatr &a)
MBDLL_DECL Stream &  operator== (Stream &s, aenum &a)
MBDLL_DECL Stream &  operator== (Stream &s, afilename &a)

Define Documentation

#define DECLARE_CLASS
 

Value:

private: \
    static mudbox::ClassDesc s_cMyClass; \
public: \
    virtual const mudbox::ClassDesc *RuntimeClass( void ) const { return &s_cMyClass; }; \
    static const mudbox::ClassDesc *StaticClass( void ); \
    static mudbox::Node *CreateInstances( unsigned int iCount = 1 );
This macro should be used in declaration of classes which are inherited from the Node class (or any descendant of that) to fill RTTI information.

You have to use this with the IMPLEMENT_CLASS macro. Example:

    class MyClass : public Node
    {
        DECLARE_CLASS
        // other members follow
    }
in the corresponding cpp file:
    #include "MyClass.h"
    IMPLEMENT_CLASS( MyClass, Node, "My Class" );
After this you will be able to access the following functionality: 1. Your class will be listed as the implemented classes in mudbox. This means that other plugins, or mudbox itself will be able to create instances of your class. See the Imported class for more details. 2. It will be possible to identify the runtime type of your objects.
#define IMPLEMENT_SDK_VCLASS2 name,
parent0,
parent1,
displayname,
instanceclass,
version,
streamversion   ) 
 

Value:

mudbox::ClassDesc name::s_cMyClass( parent0::StaticClass(), parent1::StaticClass(), #name, displayname, name::CreateInstances, version, streamversion ); \
    const mudbox::ClassDesc *name::StaticClass( void ) { return &s_cMyClass; }; \
    mudbox::Node *name::CreateInstances( unsigned int iCount ) \
        { Node *p; \
            if ( iCount > 1 ) { p = new instanceclass[iCount]; for ( unsigned int i = 0; i < iCount; i++ ) p[i].Initialize(); } \
            else { p = new instanceclass; p->Initialize(); }; \
            return p; };
#define IMPLEMENT_SDK_CLASS name,
parent,
displayname,
instanceclass   )     IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, instanceclass, 0, 0 )
 
#define IMPLEMENT_VCLASS2 name,
parent0,
parent1,
displayname,
version   )     IMPLEMENT_SDK_VCLASS2( name, parent0, parent1, displayname, name, version, 0 )
 
#define IMPLEMENT_VCLASS name,
parent,
displayname,
version   )     IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, name, version, 0 )
 
#define IMPLEMENT_CLASS2 name,
parent0,
parent1,
displayname   )     IMPLEMENT_SDK_VCLASS2( name, parent0, parent1, displayname, name, 0, 0 )
 
#define IMPLEMENT_CLASS name,
parent,
displayname   )     IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, name, 0, 0 )
 
#define IMPLEMENT_SCLASS name,
parent,
displayname,
streamversion   )     IMPLEMENT_SDK_VCLASS2( name, parent, parent, displayname, name, 0, streamversion )
 

This macro is the same as the IMPLEMENT_CLASS macro, but it also accepts an additional parameter, which is the stream version for the class.

When the IMPLEMENT_CLASS macro is used, the local stream version for the class is default to zero. This version number will be automatically written to each stream. When the stream is loaded, you can check which version of your class implementation was writing it, so you know how to read the content of the file. Normally you increase the local version number in your class by 1, when you change something in your Serialize function implementation. For example id your serialize function looks like this:

    IMPLEMENT_SCLASS( MyClass, Node, "MyClass", 4 );
   
    void MyClass::Serialize( Stream &s )
    {
        s == m_bEnabled == m_sName;
    };
And you want to add a new member variable to the stream, you change the code to the following:
    IMPLEMENT_SCLASS( MyClass, Node, "MyClass", 5 );
   
    void MyClass::Serialize( Stream &s )
    {
        s == m_bEnabled == m_sName;
       if ( s.IsNewerThan( 4, this )
            s == m_iLevel;  // this path will be executed when you load/save the most recent file format
        else
            m_iLevel = 0;   // and this path will be executed when you load an old file format
    };
This way, you will be able to load old files without problem, and maintain compatibility.
#define OPERATORS_NOEXCMARK type   ) 
 

Value:

 \
    inline operator const type( void ) const { return AttributeInstance<type>::Value(); }; \ \
    inline type const &operator ~( void ) const { return AttributeInstance<type>::Value(); }; \ \
    inline type operator =( type cValue ) { SetValue( cValue, true ); return cValue; }; \ \
    inline type operator =( const AttributeInstance<type> &cValue ) { /*AttributeInstance<type>::*/SetValue( cValue.AttributeInstance<type>::Value(), true ); return cValue; }; \ \
    inline bool operator ==( type cValue ) const { return AttributeInstance<type>::Value() == cValue; }; \ \
    inline bool operator !=( type cValue ) const { return AttributeInstance<type>::Value() != cValue; }; \ \
    inline const QString &operator <<=( const QString &sCategory ) { AttributeInstance<type>::SetCategory( sCategory ); return sCategory; };
#define OPERATORS type   ) 
 

Value:

OPERATORS_NOEXCMARK( type ) \ \
    inline bool operator !( void ) { return !AttributeInstance<type>::Value(); };
#define PTROPERATORS type   ) 
 

Value:

OPERATORS( type* ); \ \
    inline type *operator =( int iValue ) { MB_ASSERT( iValue == 0 ); return operator =( (type *)(uint64)iValue ); }; \ \
    inline bool operator ==( int iValue ) { MB_ASSERT( iValue == 0 ); return operator ==( (type *)(uint64)iValue ); }; \ \
    inline bool operator !=( int iValue ) { MB_ASSERT( iValue == 0 ); return operator !=( (type *)(uint64)iValue ); }; \ \
    inline type *operator ->( void ) { return AttributeInstance<type *>::Value(); }; \ \
    inline const type *operator ->( void ) const { return AttributeInstance<type *>::Value(); }; \ \
    inline operator bool( void ) const { return AttributeInstance<type *>::Value() != 0; };
#define aptr   AttributePointer
 

Typedef Documentation

typedef AttributeVoid mudbox::avoid
 
typedef AttributeInstance<int> mudbox::aint
 

This type has to be used instead of the general int type.

typedef AttributeInstance<float> mudbox::afloat
 

This type has to be used instead of the general float type.

typedef AttributeInstance<bool> mudbox::abool
 

This type has to be used instead of the general bool type.

typedef AttributeInstance<QString> mudbox::astring
 

This type has to be used instead of the String type.

typedef EventGate mudbox::aevent
 
typedef AttributeFloatRange mudbox::afloatr
 
typedef AttributeNumber mudbox::anumber
 
typedef AttributeEnumeration mudbox::aenum
 
typedef AttributeFilename mudbox::afilename
 
typedef AttributeTextureFilename mudbox::atexturefilename
 
typedef AttributeBoolCollection mudbox::aboolc
 

Enumeration Type Documentation

enum NodeEventType
 

Possible event types when Node::OnNodeEvent is called.

Enumeration values:
etValueChanged  Value of an attribute is changed.
etSourceChanged  The attribute is relinked to another attribute, so source is changed.
etTargetChanged  A new attribute is linked to this one, or a link is removed.
etPointerContentChanged  This is valid only for pointer type attributes (See AttributePointer). This is posted when the target node of the pointer is changed (See Node::ContentChanged()).
etPointerTargetDestroyed  This is valid only for pointer type attributes (See AttributePointer). The target node of the pointer is about to destroyed.
etStatusChanged  Status of the attribute is changed (See SetConst()).
etPointerTargetUIChanged  UI data in attributes are changed.
etDeferred  Previously requested deferred event.
etRefreshDialogUI  Causes entire dialog to refresh its UI.

Should be used at the end of a batch job.

etEventTriggered  An event triggered.
00140 {
00142     etValueChanged,
00144     etSourceChanged,
00146     etTargetChanged,
00148     etPointerContentChanged,
00150     etPointerTargetDestroyed,
00152     etStatusChanged,
00154     etPointerTargetUIChanged,
00156     etDeferred,
00159     etRefreshDialogUI,
00161     etEventTriggered = etValueChanged
00162 };

Function Documentation

MBDLL_DECL AttributeWidget* CreateNewPtrWidget QWidget *  pParent,
int  iWidth,
Attribute *  pAttribute,
const ClassDesc *  pType
 
MBDLL_DECL AttributeWidget* CreateNewBoolWidget QWidget *  pParent,
int  iWidth,
abool pAttribute
 
MBDLL_DECL AttributeWidget* CreateNewIntWidget QWidget *  pParent,
int  iWidth,
aint pAttribute
 
template<typename type>
bool operator== const Attribute &  cA,
const AttributeInstance< type > &  cB
[inline]
 

This operator compares the two attributes and NOT their values. Returns true only if the two attribute instances are the same (See Node::OnNodeEvent).

00520                                                                         { return CreateNewIntWidget( pParent, iWidth, this ); };
00521 
00523 template < typename type > inline
template<typename type>
Stream& operator== Stream &  s,
AttributeInstance< type > &  c
[inline]
 
00531 {
template<typename type>
Stream& operator== Stream &  cStream,
AttributePointer< type > &  cPointer
[inline]
 
00657 { cPointer.AttributePointer<type>::Serialize( cStream ); return cStream; };
AttributeWidget* CreateNewEventWidget QWidget *  pParent,
int  iWidth,
EventGate *  pAttribute
 

Creates an event widget.

MBDLL_DECL Stream& operator== Stream &  s,
afloatr a
 
MBDLL_DECL Stream& operator== Stream &  s,
aenum a
 
MBDLL_DECL Stream& operator== Stream &  s,
afilename a